import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false

import UIRouter from "./components/UI Router"
import Contacts from "./components/Contacts"
import About from "./components/About"
import Allcontacts from "./components/Allcontacts"
import Alice from "./components/Alice"
import Bob from "./components/Bob"
import blog from "./components/blog"
import fax from "./components/fax"

import VueRouter from 'vue-router'

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {

  return originalPush.call(this, location).catch(err => err)

}
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/UIRouter'
  },
  {
    path: '/UIRouter',
    component: UIRouter
  },
  {
    path: '/Contacts',
    component: Contacts,
    children: [
      {
        path: '/',
        redirect: '/Contacts/Allcontacts'
      },
      {
        path: '/Contacts/Allcontacts',
        component: Allcontacts
      },
      {
        path: '/Contacts/Alice',
        component: Alice
      },
      {
        path: '/Contacts/Bob',
        component: Bob,
        children: [
          {
            path: '/Contacts/Bob/blog',
            component: blog
          },
          {
            path: '/Contacts/Bob/fax',
            component: fax
          }
        ]
      }
    ]
  },
  {
    path: '/About',
    component: About
  },
]
const router = new VueRouter({
  routes
})

new Vue({
  router,
  render: h => h(App),
}).$mount('#app')
